package com.qf.controller;

import com.qf.dto.R;
import com.qf.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/*
 *  @author Administrator
 *  @version V1.0
 *  @Project banwoqiche
 *  @Package com.qf.controller
 *  @Description
 *  @Date2022/3/29 0029 17:31
 */
@RestController
@RequestMapping("/member")
public class MemberController {
    private MemberService memberService;

    @Autowired
    public void setMemberService(MemberService memberService) {
        this.memberService = memberService;
    }
    @PreAuthorize("hasAuthority('sys:menu:list,sys:menu:info')")
    @GetMapping("/all")//查询所有会员
    public R findAll(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer limit) {
        return R.setOk(memberService.findAll(page, limit));
    }

    @PreAuthorize("hasAuthority('sys:menu:list,sys:menu:info')")
    @GetMapping("/activity")//查询活动
    public R findAllFavActivity(Integer memberId) {
        return R.setOk(memberService.findAllFavActivity(memberId));
    }

    @PreAuthorize("hasAuthority('sys:menu:list,sys:menu:info')")
    @GetMapping("/airticle")//查询资讯
    public R findAllFavAirticle(Integer memberId){
        return R.setOk(memberService.findAllFavAirticle(memberId));
    }
    @PreAuthorize("hasAuthority('sys:menu:list,sys:menu:info')")
    @GetMapping("/car")//查询车
    public R findAllFavCar(Integer memberId){
        return R.setOk(memberService.findAllFavCar(memberId));
    }

    @PreAuthorize("hasAuthority('sys:menu:list,sys:menu:info')")
    @GetMapping("/tag")//查询所有标签
    public R findAllTag(Integer memberId) {
        return R.setOk(memberService.findAllTag(memberId));
    }

}
